/*
 * TestCreatingMultipleStoragesResources.cpp
 *
 *  Created on: 31/10/2009
 *      Author: ngonzalez
 */

#include <iostream>
#include "../Externa/Clave.h"
#include "../Externa/Dato.h"
#include "Alumno.h"
#include "../StorageResourceFactory.h"


using namespace std;

class TestCreatingMultipleStoragesResources {

	StorageResourceFactory *storageResourceFactory;
	StorageResource *storageResource;
	StorageResource *storageResource2;
	string fileName;

public:

	void Setup () {
		storageResourceFactory = new StorageResourceFactory();
		storageResourceFactory->createStorageTextResource("Testing_31_11.txt");
		storageResource = storageResourceFactory->getStorageResource();

		storageResourceFactory->createStorageTextResource("Testing_32_11.txt");
		storageResource2 = storageResourceFactory->getStorageResource();

		//TODO Aca habria que seguir poniendo recursos de todo tipo.
	}

	void Terminar () {
		delete storageResourceFactory;
		delete storageResource;
		delete storageResource2;
		cout << "El test de TestCreatingMultipleStoragesResources se completo"<< endl;
	}

	void testSaveData () {

		Alumno *alumno = new Alumno();
		storageResource->setData(alumno);
		Clave clave("dni",storageResource->getDato());
		storageResource->setClave(&clave);
		storageResource->saveData();


		Alumno *alumno2 = new Alumno();
		storageResource2->setData(alumno2);
		Clave clave2("dni",storageResource->getDato());
		storageResource2->setClave(&clave2);
		storageResource2->saveData();
	}

	void Run() {
		Setup();
		testSaveData();
		Terminar();
	}
};
